package com.mfin.bom.factory;

import com.mfin.bom.adapter.FinanceLoanAdapter;
import com.mfin.bom.factory.interfaces.IFinanceLoanInformationFactory;
import com.mfin.bom.interfaces.IFinanceLoan;
import com.mfin.bom.objects.FinanceLoan;
import com.mfin.vo.ObjectKey;
import com.mfin.vo.interfaces.IIdentifiableObject;

public class FinanceLoanInformationFactory extends BaseFactory implements
		IFinanceLoanInformationFactory {

	@Override
	public IFinanceLoan getLoan(IIdentifiableObject identifiableObject) {
		IFinanceLoan fl = null;
		ObjectKey[] keys = identifiableObject.getKeys();

		try {
			FinanceLoan f = (FinanceLoan) getPersistenceGovernor().get(
					FinanceLoan.class, keys[2].getId());

			if (f != null) {
				fl = new FinanceLoanAdapter(f, keys);
			}
		} catch (Exception ex) {
			// throw some exception
			ex.printStackTrace();
		}
		return fl;
	}
}
